package com.sghd.candy.module.skill.manager;

import com.sghd.common.ramcache.anno.Inject;
import com.sghd.common.ramcache.service.EntityCacheService;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author Allen
 * @date 2018/12/06
 */
@Component
public class PlayerSkillManager {
    @Inject
    private EntityCacheService<Long, PlayerSkill> skillCache;

    public void setFightSkill(PlayerSkill playerSkill, Set<Integer> fightSkill) {
        playerSkill.setFightSkill(fightSkill);
    }
    public void addFightSkill(PlayerSkill playerSkill, int skillId) {
        playerSkill.addFightSkill(skillId);
    }
    public void removeFightSkill(PlayerSkill playerSkill, int skillId) {
        playerSkill.removeFightSkill(skillId);
    }
    public void addPlayerSkill(PlayerSkill playerSkill, Set<Integer> newSkill) {
        playerSkill.addPlayerSkill(newSkill);
    }

    public void addPlayerSkill(PlayerSkill playerSkill, int skillId) {
        playerSkill.addPlayerSkill(skillId);
    }
    public PlayerSkill getPlayerSkill(long playerId) {
        return skillCache.loadOrCreate(playerId, builder -> PlayerSkill.valueOf(playerId));
    }

    public void upgradeSkill(PlayerSkill playerSkill, int skillId, int disCount) {
        playerSkill.upgradeSkill(skillId, disCount);
    }

    public void change(PlayerSkill playerSkill, int changeNum) {
        playerSkill.change(changeNum);
    }
}
